/*
 * Copyright 2018 Google
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: firestore/local/target.proto

#include "firestore/local/target.pb.h"

#include <algorithm>

#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/port.h>
#include <google/protobuf/stubs/once.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/wire_format_lite_inl.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/reflection_ops.h>
#include <google/protobuf/wire_format.h>
// This is a temporary google only hack
#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
#include "third_party/protobuf/version.h"
#endif
// @@protoc_insertion_point(includes)
namespace firestore {
namespace client {
class TargetDefaultTypeInternal {
 public:
  ::google::protobuf::internal::ExplicitlyConstructed<Target>
      _instance;
  const ::google::firestore::v1beta1::Target_QueryTarget* query_;
  const ::google::firestore::v1beta1::Target_DocumentsTarget* documents_;
} _Target_default_instance_;
class TargetGlobalDefaultTypeInternal {
 public:
  ::google::protobuf::internal::ExplicitlyConstructed<TargetGlobal>
      _instance;
} _TargetGlobal_default_instance_;
}  // namespace client
}  // namespace firestore
namespace protobuf_firestore_2flocal_2ftarget_2eproto {
void InitDefaultsTargetImpl() {
  GOOGLE_PROTOBUF_VERIFY_VERSION;

#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
  ::google::protobuf::internal::InitProtobufDefaultsForceUnique();
#else
  ::google::protobuf::internal::InitProtobufDefaults();
#endif  // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
  protobuf_google_2fprotobuf_2ftimestamp_2eproto::InitDefaultsTimestamp();
  protobuf_google_2ffirestore_2fv1beta1_2ffirestore_2eproto::InitDefaultsTarget_QueryTarget();
  protobuf_google_2ffirestore_2fv1beta1_2ffirestore_2eproto::InitDefaultsTarget_DocumentsTarget();
  {
    void* ptr = &::firestore::client::_Target_default_instance_;
    new (ptr) ::firestore::client::Target();
    ::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
  }
  ::firestore::client::Target::InitAsDefaultInstance();
}

void InitDefaultsTarget() {
  static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
  ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsTargetImpl);
}

void InitDefaultsTargetGlobalImpl() {
  GOOGLE_PROTOBUF_VERIFY_VERSION;

#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
  ::google::protobuf::internal::InitProtobufDefaultsForceUnique();
#else
  ::google::protobuf::internal::InitProtobufDefaults();
#endif  // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
  protobuf_google_2fprotobuf_2ftimestamp_2eproto::InitDefaultsTimestamp();
  {
    void* ptr = &::firestore::client::_TargetGlobal_default_instance_;
    new (ptr) ::firestore::client::TargetGlobal();
    ::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
  }
  ::firestore::client::TargetGlobal::InitAsDefaultInstance();
}

void InitDefaultsTargetGlobal() {
  static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
  ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsTargetGlobalImpl);
}

::google::protobuf::Metadata file_level_metadata[2];

const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
  ~0u,  // no _has_bits_
  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::firestore::client::Target, _internal_metadata_),
  ~0u,  // no _extensions_
  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::firestore::client::Target, _oneof_case_[0]),
  ~0u,  // no _weak_field_map_
  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::firestore::client::Target, target_id_),
  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::firestore::client::Target, snapshot_version_),
  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::firestore::client::Target, resume_token_),
  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::firestore::client::Target, last_listen_sequence_number_),
  offsetof(::firestore::client::TargetDefaultTypeInternal, query_),
  offsetof(::firestore::client::TargetDefaultTypeInternal, documents_),
  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::firestore::client::Target, target_type_),
  ~0u,  // no _has_bits_
  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::firestore::client::TargetGlobal, _internal_metadata_),
  ~0u,  // no _extensions_
  ~0u,  // no _oneof_case_
  ~0u,  // no _weak_field_map_
  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::firestore::client::TargetGlobal, highest_target_id_),
  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::firestore::client::TargetGlobal, highest_listen_sequence_number_),
  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::firestore::client::TargetGlobal, last_remote_snapshot_version_),
  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::firestore::client::TargetGlobal, target_count_),
};
static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
  { 0, -1, sizeof(::firestore::client::Target)},
  { 12, -1, sizeof(::firestore::client::TargetGlobal)},
};

static ::google::protobuf::Message const * const file_default_instances[] = {
  reinterpret_cast<const ::google::protobuf::Message*>(&::firestore::client::_Target_default_instance_),
  reinterpret_cast<const ::google::protobuf::Message*>(&::firestore::client::_TargetGlobal_default_instance_),
};

void protobuf_AssignDescriptors() {
  AddDescriptors();
  ::google::protobuf::MessageFactory* factory = NULL;
  AssignDescriptors(
      "firestore/local/target.proto", schemas, file_default_instances, TableStruct::offsets, factory,
      file_level_metadata, NULL, NULL);
}

void protobuf_AssignDescriptorsOnce() {
  static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
  ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors);
}

void protobuf_RegisterTypes(const ::std::string&) GOOGLE_PROTOBUF_ATTRIBUTE_COLD;
void protobuf_RegisterTypes(const ::std::string&) {
  protobuf_AssignDescriptorsOnce();
  ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 2);
}

void AddDescriptorsImpl() {
  InitDefaults();
  static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
      "\n\034firestore/local/target.proto\022\020firestor"
      "e.client\032(google/firestore/v1beta1/fires"
      "tore.proto\032\037google/protobuf/timestamp.pr"
      "oto\"\241\002\n\006Target\022\021\n\ttarget_id\030\001 \001(\005\0224\n\020sna"
      "pshot_version\030\002 \001(\0132\032.google.protobuf.Ti"
      "mestamp\022\024\n\014resume_token\030\003 \001(\014\022#\n\033last_li"
      "sten_sequence_number\030\004 \001(\003\022=\n\005query\030\005 \001("
      "\0132,.google.firestore.v1beta1.Target.Quer"
      "yTargetH\000\022E\n\tdocuments\030\006 \001(\01320.google.fi"
      "restore.v1beta1.Target.DocumentsTargetH\000"
      "B\r\n\013target_type\"\251\001\n\014TargetGlobal\022\031\n\021high"
      "est_target_id\030\001 \001(\005\022&\n\036highest_listen_se"
      "quence_number\030\002 \001(\003\022@\n\034last_remote_snaps"
      "hot_version\030\003 \001(\0132\032.google.protobuf.Time"
      "stamp\022\024\n\014target_count\030\004 \001(\005B/\n#com.googl"
      "e.firebase.firestore.protoP\001\242\002\005FSTPBb\006pr"
      "oto3"
  };
  ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
      descriptor, 644);
  ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
    "firestore/local/target.proto", &protobuf_RegisterTypes);
  ::protobuf_google_2ffirestore_2fv1beta1_2ffirestore_2eproto::AddDescriptors();
  ::protobuf_google_2fprotobuf_2ftimestamp_2eproto::AddDescriptors();
}

void AddDescriptors() {
  static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
  ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);
}
// Force AddDescriptors() to be called at dynamic initialization time.
struct StaticDescriptorInitializer {
  StaticDescriptorInitializer() {
    AddDescriptors();
  }
} static_descriptor_initializer;
}  // namespace protobuf_firestore_2flocal_2ftarget_2eproto
namespace firestore {
namespace client {

// ===================================================================

void Target::InitAsDefaultInstance() {
  ::firestore::client::_Target_default_instance_._instance.get_mutable()->snapshot_version_ = const_cast< ::google::protobuf::Timestamp*>(
      ::google::protobuf::Timestamp::internal_default_instance());
  ::firestore::client::_Target_default_instance_.query_ = const_cast< ::google::firestore::v1beta1::Target_QueryTarget*>(
      ::google::firestore::v1beta1::Target_QueryTarget::internal_default_instance());
  ::firestore::client::_Target_default_instance_.documents_ = const_cast< ::google::firestore::v1beta1::Target_DocumentsTarget*>(
      ::google::firestore::v1beta1::Target_DocumentsTarget::internal_default_instance());
}
void Target::clear_snapshot_version() {
  if (GetArenaNoVirtual() == NULL && snapshot_version_ != NULL) {
    delete snapshot_version_;
  }
  snapshot_version_ = NULL;
}
void Target::set_allocated_query(::google::firestore::v1beta1::Target_QueryTarget* query) {
  ::google::protobuf::Arena* message_arena = GetArenaNoVirtual();
  clear_target_type();
  if (query) {
    ::google::protobuf::Arena* submessage_arena = NULL;
    if (message_arena != submessage_arena) {
      query = ::google::protobuf::internal::GetOwnedMessage(
          message_arena, query, submessage_arena);
    }
    set_has_query();
    target_type_.query_ = query;
  }
  // @@protoc_insertion_point(field_set_allocated:firestore.client.Target.query)
}
void Target::clear_query() {
  if (has_query()) {
    delete target_type_.query_;
    clear_has_target_type();
  }
}
void Target::set_allocated_documents(::google::firestore::v1beta1::Target_DocumentsTarget* documents) {
  ::google::protobuf::Arena* message_arena = GetArenaNoVirtual();
  clear_target_type();
  if (documents) {
    ::google::protobuf::Arena* submessage_arena = NULL;
    if (message_arena != submessage_arena) {
      documents = ::google::protobuf::internal::GetOwnedMessage(
          message_arena, documents, submessage_arena);
    }
    set_has_documents();
    target_type_.documents_ = documents;
  }
  // @@protoc_insertion_point(field_set_allocated:firestore.client.Target.documents)
}
void Target::clear_documents() {
  if (has_documents()) {
    delete target_type_.documents_;
    clear_has_target_type();
  }
}
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int Target::kTargetIdFieldNumber;
const int Target::kSnapshotVersionFieldNumber;
const int Target::kResumeTokenFieldNumber;
const int Target::kLastListenSequenceNumberFieldNumber;
const int Target::kQueryFieldNumber;
const int Target::kDocumentsFieldNumber;
#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900

Target::Target()
  : ::google::protobuf::Message(), _internal_metadata_(NULL) {
  if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
    ::protobuf_firestore_2flocal_2ftarget_2eproto::InitDefaultsTarget();
  }
  SharedCtor();
  // @@protoc_insertion_point(constructor:firestore.client.Target)
}
Target::Target(const Target& from)
  : ::google::protobuf::Message(),
      _internal_metadata_(NULL),
      _cached_size_(0) {
  _internal_metadata_.MergeFrom(from._internal_metadata_);
  resume_token_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
  if (from.resume_token().size() > 0) {
    resume_token_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.resume_token_);
  }
  if (from.has_snapshot_version()) {
    snapshot_version_ = new ::google::protobuf::Timestamp(*from.snapshot_version_);
  } else {
    snapshot_version_ = NULL;
  }
  ::memcpy(&last_listen_sequence_number_, &from.last_listen_sequence_number_,
    static_cast<size_t>(reinterpret_cast<char*>(&target_id_) -
    reinterpret_cast<char*>(&last_listen_sequence_number_)) + sizeof(target_id_));
  clear_has_target_type();
  switch (from.target_type_case()) {
    case kQuery: {
      mutable_query()->::google::firestore::v1beta1::Target_QueryTarget::MergeFrom(from.query());
      break;
    }
    case kDocuments: {
      mutable_documents()->::google::firestore::v1beta1::Target_DocumentsTarget::MergeFrom(from.documents());
      break;
    }
    case TARGET_TYPE_NOT_SET: {
      break;
    }
  }
  // @@protoc_insertion_point(copy_constructor:firestore.client.Target)
}

void Target::SharedCtor() {
  resume_token_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
  ::memset(&snapshot_version_, 0, static_cast<size_t>(
      reinterpret_cast<char*>(&target_id_) -
      reinterpret_cast<char*>(&snapshot_version_)) + sizeof(target_id_));
  clear_has_target_type();
  _cached_size_ = 0;
}

Target::~Target() {
  // @@protoc_insertion_point(destructor:firestore.client.Target)
  SharedDtor();
}

void Target::SharedDtor() {
  resume_token_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
  if (this != internal_default_instance()) delete snapshot_version_;
  if (has_target_type()) {
    clear_target_type();
  }
}

void Target::SetCachedSize(int size) const {
  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
  _cached_size_ = size;
  GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* Target::descriptor() {
  ::protobuf_firestore_2flocal_2ftarget_2eproto::protobuf_AssignDescriptorsOnce();
  return ::protobuf_firestore_2flocal_2ftarget_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}

const Target& Target::default_instance() {
  ::protobuf_firestore_2flocal_2ftarget_2eproto::InitDefaultsTarget();
  return *internal_default_instance();
}

Target* Target::New(::google::protobuf::Arena* arena) const {
  Target* n = new Target;
  if (arena != NULL) {
    arena->Own(n);
  }
  return n;
}

void Target::clear_target_type() {
// @@protoc_insertion_point(one_of_clear_start:firestore.client.Target)
  switch (target_type_case()) {
    case kQuery: {
      delete target_type_.query_;
      break;
    }
    case kDocuments: {
      delete target_type_.documents_;
      break;
    }
    case TARGET_TYPE_NOT_SET: {
      break;
    }
  }
  _oneof_case_[0] = TARGET_TYPE_NOT_SET;
}


void Target::Clear() {
// @@protoc_insertion_point(message_clear_start:firestore.client.Target)
  ::google::protobuf::uint32 cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  resume_token_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
  if (GetArenaNoVirtual() == NULL && snapshot_version_ != NULL) {
    delete snapshot_version_;
  }
  snapshot_version_ = NULL;
  ::memset(&last_listen_sequence_number_, 0, static_cast<size_t>(
      reinterpret_cast<char*>(&target_id_) -
      reinterpret_cast<char*>(&last_listen_sequence_number_)) + sizeof(target_id_));
  clear_target_type();
  _internal_metadata_.Clear();
}

bool Target::MergePartialFromCodedStream(
    ::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
  ::google::protobuf::uint32 tag;
  // @@protoc_insertion_point(parse_start:firestore.client.Target)
  for (;;) {
    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
    tag = p.first;
    if (!p.second) goto handle_unusual;
    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
      // int32 target_id = 1;
      case 1: {
        if (static_cast< ::google::protobuf::uint8>(tag) ==
            static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) {

          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
                 input, &target_id_)));
        } else {
          goto handle_unusual;
        }
        break;
      }

      // .google.protobuf.Timestamp snapshot_version = 2;
      case 2: {
        if (static_cast< ::google::protobuf::uint8>(tag) ==
            static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) {
          DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
               input, mutable_snapshot_version()));
        } else {
          goto handle_unusual;
        }
        break;
      }

      // bytes resume_token = 3;
      case 3: {
        if (static_cast< ::google::protobuf::uint8>(tag) ==
            static_cast< ::google::protobuf::uint8>(26u /* 26 & 0xFF */)) {
          DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(
                input, this->mutable_resume_token()));
        } else {
          goto handle_unusual;
        }
        break;
      }

      // int64 last_listen_sequence_number = 4;
      case 4: {
        if (static_cast< ::google::protobuf::uint8>(tag) ==
            static_cast< ::google::protobuf::uint8>(32u /* 32 & 0xFF */)) {

          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
                   ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>(
                 input, &last_listen_sequence_number_)));
        } else {
          goto handle_unusual;
        }
        break;
      }

      // .google.firestore.v1beta1.Target.QueryTarget query = 5;
      case 5: {
        if (static_cast< ::google::protobuf::uint8>(tag) ==
            static_cast< ::google::protobuf::uint8>(42u /* 42 & 0xFF */)) {
          DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
               input, mutable_query()));
        } else {
          goto handle_unusual;
        }
        break;
      }

      // .google.firestore.v1beta1.Target.DocumentsTarget documents = 6;
      case 6: {
        if (static_cast< ::google::protobuf::uint8>(tag) ==
            static_cast< ::google::protobuf::uint8>(50u /* 50 & 0xFF */)) {
          DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
               input, mutable_documents()));
        } else {
          goto handle_unusual;
        }
        break;
      }

      default: {
      handle_unusual:
        if (tag == 0) {
          goto success;
        }
        DO_(::google::protobuf::internal::WireFormat::SkipField(
              input, tag, _internal_metadata_.mutable_unknown_fields()));
        break;
      }
    }
  }
success:
  // @@protoc_insertion_point(parse_success:firestore.client.Target)
  return true;
failure:
  // @@protoc_insertion_point(parse_failure:firestore.client.Target)
  return false;
#undef DO_
}

void Target::SerializeWithCachedSizes(
    ::google::protobuf::io::CodedOutputStream* output) const {
  // @@protoc_insertion_point(serialize_start:firestore.client.Target)
  ::google::protobuf::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  // int32 target_id = 1;
  if (this->target_id() != 0) {
    ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->target_id(), output);
  }

  // .google.protobuf.Timestamp snapshot_version = 2;
  if (this->has_snapshot_version()) {
    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
      2, *this->snapshot_version_, output);
  }

  // bytes resume_token = 3;
  if (this->resume_token().size() > 0) {
    ::google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(
      3, this->resume_token(), output);
  }

  // int64 last_listen_sequence_number = 4;
  if (this->last_listen_sequence_number() != 0) {
    ::google::protobuf::internal::WireFormatLite::WriteInt64(4, this->last_listen_sequence_number(), output);
  }

  // .google.firestore.v1beta1.Target.QueryTarget query = 5;
  if (has_query()) {
    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
      5, *target_type_.query_, output);
  }

  // .google.firestore.v1beta1.Target.DocumentsTarget documents = 6;
  if (has_documents()) {
    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
      6, *target_type_.documents_, output);
  }

  if ((_internal_metadata_.have_unknown_fields() &&  ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
        (::google::protobuf::internal::GetProto3PreserveUnknownsDefault()   ? _internal_metadata_.unknown_fields()   : _internal_metadata_.default_instance()), output);
  }
  // @@protoc_insertion_point(serialize_end:firestore.client.Target)
}

::google::protobuf::uint8* Target::InternalSerializeWithCachedSizesToArray(
    bool deterministic, ::google::protobuf::uint8* target) const {
  (void)deterministic; // Unused
  // @@protoc_insertion_point(serialize_to_array_start:firestore.client.Target)
  ::google::protobuf::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  // int32 target_id = 1;
  if (this->target_id() != 0) {
    target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->target_id(), target);
  }

  // .google.protobuf.Timestamp snapshot_version = 2;
  if (this->has_snapshot_version()) {
    target = ::google::protobuf::internal::WireFormatLite::
      InternalWriteMessageToArray(
        2, *this->snapshot_version_, deterministic, target);
  }

  // bytes resume_token = 3;
  if (this->resume_token().size() > 0) {
    target =
      ::google::protobuf::internal::WireFormatLite::WriteBytesToArray(
        3, this->resume_token(), target);
  }

  // int64 last_listen_sequence_number = 4;
  if (this->last_listen_sequence_number() != 0) {
    target = ::google::protobuf::internal::WireFormatLite::WriteInt64ToArray(4, this->last_listen_sequence_number(), target);
  }

  // .google.firestore.v1beta1.Target.QueryTarget query = 5;
  if (has_query()) {
    target = ::google::protobuf::internal::WireFormatLite::
      InternalWriteMessageToArray(
        5, *target_type_.query_, deterministic, target);
  }

  // .google.firestore.v1beta1.Target.DocumentsTarget documents = 6;
  if (has_documents()) {
    target = ::google::protobuf::internal::WireFormatLite::
      InternalWriteMessageToArray(
        6, *target_type_.documents_, deterministic, target);
  }

  if ((_internal_metadata_.have_unknown_fields() &&  ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
        (::google::protobuf::internal::GetProto3PreserveUnknownsDefault()   ? _internal_metadata_.unknown_fields()   : _internal_metadata_.default_instance()), target);
  }
  // @@protoc_insertion_point(serialize_to_array_end:firestore.client.Target)
  return target;
}

size_t Target::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:firestore.client.Target)
  size_t total_size = 0;

  if ((_internal_metadata_.have_unknown_fields() &&  ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
    total_size +=
      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
        (::google::protobuf::internal::GetProto3PreserveUnknownsDefault()   ? _internal_metadata_.unknown_fields()   : _internal_metadata_.default_instance()));
  }
  // bytes resume_token = 3;
  if (this->resume_token().size() > 0) {
    total_size += 1 +
      ::google::protobuf::internal::WireFormatLite::BytesSize(
        this->resume_token());
  }

  // .google.protobuf.Timestamp snapshot_version = 2;
  if (this->has_snapshot_version()) {
    total_size += 1 +
      ::google::protobuf::internal::WireFormatLite::MessageSize(
        *this->snapshot_version_);
  }

  // int64 last_listen_sequence_number = 4;
  if (this->last_listen_sequence_number() != 0) {
    total_size += 1 +
      ::google::protobuf::internal::WireFormatLite::Int64Size(
        this->last_listen_sequence_number());
  }

  // int32 target_id = 1;
  if (this->target_id() != 0) {
    total_size += 1 +
      ::google::protobuf::internal::WireFormatLite::Int32Size(
        this->target_id());
  }

  switch (target_type_case()) {
    // .google.firestore.v1beta1.Target.QueryTarget query = 5;
    case kQuery: {
      total_size += 1 +
        ::google::protobuf::internal::WireFormatLite::MessageSize(
          *target_type_.query_);
      break;
    }
    // .google.firestore.v1beta1.Target.DocumentsTarget documents = 6;
    case kDocuments: {
      total_size += 1 +
        ::google::protobuf::internal::WireFormatLite::MessageSize(
          *target_type_.documents_);
      break;
    }
    case TARGET_TYPE_NOT_SET: {
      break;
    }
  }
  int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
  _cached_size_ = cached_size;
  GOOGLE_SAFE_CONCURRENT_WRITES_END();
  return total_size;
}

void Target::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:firestore.client.Target)
  GOOGLE_DCHECK_NE(&from, this);
  const Target* source =
      ::google::protobuf::internal::DynamicCastToGenerated<const Target>(
          &from);
  if (source == NULL) {
  // @@protoc_insertion_point(generalized_merge_from_cast_fail:firestore.client.Target)
    ::google::protobuf::internal::ReflectionOps::Merge(from, this);
  } else {
  // @@protoc_insertion_point(generalized_merge_from_cast_success:firestore.client.Target)
    MergeFrom(*source);
  }
}

void Target::MergeFrom(const Target& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:firestore.client.Target)
  GOOGLE_DCHECK_NE(&from, this);
  _internal_metadata_.MergeFrom(from._internal_metadata_);
  ::google::protobuf::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  if (from.resume_token().size() > 0) {

    resume_token_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.resume_token_);
  }
  if (from.has_snapshot_version()) {
    mutable_snapshot_version()->::google::protobuf::Timestamp::MergeFrom(from.snapshot_version());
  }
  if (from.last_listen_sequence_number() != 0) {
    set_last_listen_sequence_number(from.last_listen_sequence_number());
  }
  if (from.target_id() != 0) {
    set_target_id(from.target_id());
  }
  switch (from.target_type_case()) {
    case kQuery: {
      mutable_query()->::google::firestore::v1beta1::Target_QueryTarget::MergeFrom(from.query());
      break;
    }
    case kDocuments: {
      mutable_documents()->::google::firestore::v1beta1::Target_DocumentsTarget::MergeFrom(from.documents());
      break;
    }
    case TARGET_TYPE_NOT_SET: {
      break;
    }
  }
}

void Target::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:firestore.client.Target)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

void Target::CopyFrom(const Target& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:firestore.client.Target)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

bool Target::IsInitialized() const {
  return true;
}

void Target::Swap(Target* other) {
  if (other == this) return;
  InternalSwap(other);
}
void Target::InternalSwap(Target* other) {
  using std::swap;
  resume_token_.Swap(&other->resume_token_);
  swap(snapshot_version_, other->snapshot_version_);
  swap(last_listen_sequence_number_, other->last_listen_sequence_number_);
  swap(target_id_, other->target_id_);
  swap(target_type_, other->target_type_);
  swap(_oneof_case_[0], other->_oneof_case_[0]);
  _internal_metadata_.Swap(&other->_internal_metadata_);
  swap(_cached_size_, other->_cached_size_);
}

::google::protobuf::Metadata Target::GetMetadata() const {
  protobuf_firestore_2flocal_2ftarget_2eproto::protobuf_AssignDescriptorsOnce();
  return ::protobuf_firestore_2flocal_2ftarget_2eproto::file_level_metadata[kIndexInFileMessages];
}


// ===================================================================

void TargetGlobal::InitAsDefaultInstance() {
  ::firestore::client::_TargetGlobal_default_instance_._instance.get_mutable()->last_remote_snapshot_version_ = const_cast< ::google::protobuf::Timestamp*>(
      ::google::protobuf::Timestamp::internal_default_instance());
}
void TargetGlobal::clear_last_remote_snapshot_version() {
  if (GetArenaNoVirtual() == NULL && last_remote_snapshot_version_ != NULL) {
    delete last_remote_snapshot_version_;
  }
  last_remote_snapshot_version_ = NULL;
}
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int TargetGlobal::kHighestTargetIdFieldNumber;
const int TargetGlobal::kHighestListenSequenceNumberFieldNumber;
const int TargetGlobal::kLastRemoteSnapshotVersionFieldNumber;
const int TargetGlobal::kTargetCountFieldNumber;
#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900

TargetGlobal::TargetGlobal()
  : ::google::protobuf::Message(), _internal_metadata_(NULL) {
  if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
    ::protobuf_firestore_2flocal_2ftarget_2eproto::InitDefaultsTargetGlobal();
  }
  SharedCtor();
  // @@protoc_insertion_point(constructor:firestore.client.TargetGlobal)
}
TargetGlobal::TargetGlobal(const TargetGlobal& from)
  : ::google::protobuf::Message(),
      _internal_metadata_(NULL),
      _cached_size_(0) {
  _internal_metadata_.MergeFrom(from._internal_metadata_);
  if (from.has_last_remote_snapshot_version()) {
    last_remote_snapshot_version_ = new ::google::protobuf::Timestamp(*from.last_remote_snapshot_version_);
  } else {
    last_remote_snapshot_version_ = NULL;
  }
  ::memcpy(&highest_listen_sequence_number_, &from.highest_listen_sequence_number_,
    static_cast<size_t>(reinterpret_cast<char*>(&target_count_) -
    reinterpret_cast<char*>(&highest_listen_sequence_number_)) + sizeof(target_count_));
  // @@protoc_insertion_point(copy_constructor:firestore.client.TargetGlobal)
}

void TargetGlobal::SharedCtor() {
  ::memset(&last_remote_snapshot_version_, 0, static_cast<size_t>(
      reinterpret_cast<char*>(&target_count_) -
      reinterpret_cast<char*>(&last_remote_snapshot_version_)) + sizeof(target_count_));
  _cached_size_ = 0;
}

TargetGlobal::~TargetGlobal() {
  // @@protoc_insertion_point(destructor:firestore.client.TargetGlobal)
  SharedDtor();
}

void TargetGlobal::SharedDtor() {
  if (this != internal_default_instance()) delete last_remote_snapshot_version_;
}

void TargetGlobal::SetCachedSize(int size) const {
  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
  _cached_size_ = size;
  GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* TargetGlobal::descriptor() {
  ::protobuf_firestore_2flocal_2ftarget_2eproto::protobuf_AssignDescriptorsOnce();
  return ::protobuf_firestore_2flocal_2ftarget_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}

const TargetGlobal& TargetGlobal::default_instance() {
  ::protobuf_firestore_2flocal_2ftarget_2eproto::InitDefaultsTargetGlobal();
  return *internal_default_instance();
}

TargetGlobal* TargetGlobal::New(::google::protobuf::Arena* arena) const {
  TargetGlobal* n = new TargetGlobal;
  if (arena != NULL) {
    arena->Own(n);
  }
  return n;
}

void TargetGlobal::Clear() {
// @@protoc_insertion_point(message_clear_start:firestore.client.TargetGlobal)
  ::google::protobuf::uint32 cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  if (GetArenaNoVirtual() == NULL && last_remote_snapshot_version_ != NULL) {
    delete last_remote_snapshot_version_;
  }
  last_remote_snapshot_version_ = NULL;
  ::memset(&highest_listen_sequence_number_, 0, static_cast<size_t>(
      reinterpret_cast<char*>(&target_count_) -
      reinterpret_cast<char*>(&highest_listen_sequence_number_)) + sizeof(target_count_));
  _internal_metadata_.Clear();
}

bool TargetGlobal::MergePartialFromCodedStream(
    ::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
  ::google::protobuf::uint32 tag;
  // @@protoc_insertion_point(parse_start:firestore.client.TargetGlobal)
  for (;;) {
    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
    tag = p.first;
    if (!p.second) goto handle_unusual;
    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
      // int32 highest_target_id = 1;
      case 1: {
        if (static_cast< ::google::protobuf::uint8>(tag) ==
            static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) {

          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
                 input, &highest_target_id_)));
        } else {
          goto handle_unusual;
        }
        break;
      }

      // int64 highest_listen_sequence_number = 2;
      case 2: {
        if (static_cast< ::google::protobuf::uint8>(tag) ==
            static_cast< ::google::protobuf::uint8>(16u /* 16 & 0xFF */)) {

          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
                   ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>(
                 input, &highest_listen_sequence_number_)));
        } else {
          goto handle_unusual;
        }
        break;
      }

      // .google.protobuf.Timestamp last_remote_snapshot_version = 3;
      case 3: {
        if (static_cast< ::google::protobuf::uint8>(tag) ==
            static_cast< ::google::protobuf::uint8>(26u /* 26 & 0xFF */)) {
          DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
               input, mutable_last_remote_snapshot_version()));
        } else {
          goto handle_unusual;
        }
        break;
      }

      // int32 target_count = 4;
      case 4: {
        if (static_cast< ::google::protobuf::uint8>(tag) ==
            static_cast< ::google::protobuf::uint8>(32u /* 32 & 0xFF */)) {

          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
                 input, &target_count_)));
        } else {
          goto handle_unusual;
        }
        break;
      }

      default: {
      handle_unusual:
        if (tag == 0) {
          goto success;
        }
        DO_(::google::protobuf::internal::WireFormat::SkipField(
              input, tag, _internal_metadata_.mutable_unknown_fields()));
        break;
      }
    }
  }
success:
  // @@protoc_insertion_point(parse_success:firestore.client.TargetGlobal)
  return true;
failure:
  // @@protoc_insertion_point(parse_failure:firestore.client.TargetGlobal)
  return false;
#undef DO_
}

void TargetGlobal::SerializeWithCachedSizes(
    ::google::protobuf::io::CodedOutputStream* output) const {
  // @@protoc_insertion_point(serialize_start:firestore.client.TargetGlobal)
  ::google::protobuf::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  // int32 highest_target_id = 1;
  if (this->highest_target_id() != 0) {
    ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->highest_target_id(), output);
  }

  // int64 highest_listen_sequence_number = 2;
  if (this->highest_listen_sequence_number() != 0) {
    ::google::protobuf::internal::WireFormatLite::WriteInt64(2, this->highest_listen_sequence_number(), output);
  }

  // .google.protobuf.Timestamp last_remote_snapshot_version = 3;
  if (this->has_last_remote_snapshot_version()) {
    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
      3, *this->last_remote_snapshot_version_, output);
  }

  // int32 target_count = 4;
  if (this->target_count() != 0) {
    ::google::protobuf::internal::WireFormatLite::WriteInt32(4, this->target_count(), output);
  }

  if ((_internal_metadata_.have_unknown_fields() &&  ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
        (::google::protobuf::internal::GetProto3PreserveUnknownsDefault()   ? _internal_metadata_.unknown_fields()   : _internal_metadata_.default_instance()), output);
  }
  // @@protoc_insertion_point(serialize_end:firestore.client.TargetGlobal)
}

::google::protobuf::uint8* TargetGlobal::InternalSerializeWithCachedSizesToArray(
    bool deterministic, ::google::protobuf::uint8* target) const {
  (void)deterministic; // Unused
  // @@protoc_insertion_point(serialize_to_array_start:firestore.client.TargetGlobal)
  ::google::protobuf::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  // int32 highest_target_id = 1;
  if (this->highest_target_id() != 0) {
    target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->highest_target_id(), target);
  }

  // int64 highest_listen_sequence_number = 2;
  if (this->highest_listen_sequence_number() != 0) {
    target = ::google::protobuf::internal::WireFormatLite::WriteInt64ToArray(2, this->highest_listen_sequence_number(), target);
  }

  // .google.protobuf.Timestamp last_remote_snapshot_version = 3;
  if (this->has_last_remote_snapshot_version()) {
    target = ::google::protobuf::internal::WireFormatLite::
      InternalWriteMessageToArray(
        3, *this->last_remote_snapshot_version_, deterministic, target);
  }

  // int32 target_count = 4;
  if (this->target_count() != 0) {
    target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(4, this->target_count(), target);
  }

  if ((_internal_metadata_.have_unknown_fields() &&  ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
        (::google::protobuf::internal::GetProto3PreserveUnknownsDefault()   ? _internal_metadata_.unknown_fields()   : _internal_metadata_.default_instance()), target);
  }
  // @@protoc_insertion_point(serialize_to_array_end:firestore.client.TargetGlobal)
  return target;
}

size_t TargetGlobal::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:firestore.client.TargetGlobal)
  size_t total_size = 0;

  if ((_internal_metadata_.have_unknown_fields() &&  ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
    total_size +=
      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
        (::google::protobuf::internal::GetProto3PreserveUnknownsDefault()   ? _internal_metadata_.unknown_fields()   : _internal_metadata_.default_instance()));
  }
  // .google.protobuf.Timestamp last_remote_snapshot_version = 3;
  if (this->has_last_remote_snapshot_version()) {
    total_size += 1 +
      ::google::protobuf::internal::WireFormatLite::MessageSize(
        *this->last_remote_snapshot_version_);
  }

  // int64 highest_listen_sequence_number = 2;
  if (this->highest_listen_sequence_number() != 0) {
    total_size += 1 +
      ::google::protobuf::internal::WireFormatLite::Int64Size(
        this->highest_listen_sequence_number());
  }

  // int32 highest_target_id = 1;
  if (this->highest_target_id() != 0) {
    total_size += 1 +
      ::google::protobuf::internal::WireFormatLite::Int32Size(
        this->highest_target_id());
  }

  // int32 target_count = 4;
  if (this->target_count() != 0) {
    total_size += 1 +
      ::google::protobuf::internal::WireFormatLite::Int32Size(
        this->target_count());
  }

  int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
  _cached_size_ = cached_size;
  GOOGLE_SAFE_CONCURRENT_WRITES_END();
  return total_size;
}

void TargetGlobal::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:firestore.client.TargetGlobal)
  GOOGLE_DCHECK_NE(&from, this);
  const TargetGlobal* source =
      ::google::protobuf::internal::DynamicCastToGenerated<const TargetGlobal>(
          &from);
  if (source == NULL) {
  // @@protoc_insertion_point(generalized_merge_from_cast_fail:firestore.client.TargetGlobal)
    ::google::protobuf::internal::ReflectionOps::Merge(from, this);
  } else {
  // @@protoc_insertion_point(generalized_merge_from_cast_success:firestore.client.TargetGlobal)
    MergeFrom(*source);
  }
}

void TargetGlobal::MergeFrom(const TargetGlobal& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:firestore.client.TargetGlobal)
  GOOGLE_DCHECK_NE(&from, this);
  _internal_metadata_.MergeFrom(from._internal_metadata_);
  ::google::protobuf::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  if (from.has_last_remote_snapshot_version()) {
    mutable_last_remote_snapshot_version()->::google::protobuf::Timestamp::MergeFrom(from.last_remote_snapshot_version());
  }
  if (from.highest_listen_sequence_number() != 0) {
    set_highest_listen_sequence_number(from.highest_listen_sequence_number());
  }
  if (from.highest_target_id() != 0) {
    set_highest_target_id(from.highest_target_id());
  }
  if (from.target_count() != 0) {
    set_target_count(from.target_count());
  }
}

void TargetGlobal::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:firestore.client.TargetGlobal)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

void TargetGlobal::CopyFrom(const TargetGlobal& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:firestore.client.TargetGlobal)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

bool TargetGlobal::IsInitialized() const {
  return true;
}

void TargetGlobal::Swap(TargetGlobal* other) {
  if (other == this) return;
  InternalSwap(other);
}
void TargetGlobal::InternalSwap(TargetGlobal* other) {
  using std::swap;
  swap(last_remote_snapshot_version_, other->last_remote_snapshot_version_);
  swap(highest_listen_sequence_number_, other->highest_listen_sequence_number_);
  swap(highest_target_id_, other->highest_target_id_);
  swap(target_count_, other->target_count_);
  _internal_metadata_.Swap(&other->_internal_metadata_);
  swap(_cached_size_, other->_cached_size_);
}

::google::protobuf::Metadata TargetGlobal::GetMetadata() const {
  protobuf_firestore_2flocal_2ftarget_2eproto::protobuf_AssignDescriptorsOnce();
  return ::protobuf_firestore_2flocal_2ftarget_2eproto::file_level_metadata[kIndexInFileMessages];
}


// @@protoc_insertion_point(namespace_scope)
}  // namespace client
}  // namespace firestore

// @@protoc_insertion_point(global_scope)
